<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); ?>
<?php 
	$ci = & get_instance(); 
	$eventCategoryDataArray = $ci->event_category_entity->getArrayIdAndNameOfEventCategory($match_id);	
	$MATCH = $ci->match_entity->init('id', $match_id);
	$TOURNAMENT = $ci->tournament_entity->init('id',$MATCH->getTournamentId());
?>
<?php if(!isset($id)): ?>
<form action="<?php echo site_url('admin/dataman/match/event_submit');?>" name="event_submit" id="event_submit" method="post" enctype="multipart/form-data" >
	<input type="hidden" name="match_id" id="match_id" value="<?php echo $match_id;?>" />
	<div class="grid2"><span class="bold">*Event Category:</span></div>
	<div class="grid6"><?php echo form_dropdown( 'event_category_id',
								$options = $eventCategoryDataArray,
								$selected = array(),
								"id='event_category_id'"
							);	?></div>	
	<div class="clrboth"></div>
	
	<div class="grid2"><span class="bold">*Event Name:</span></div>
	<div class="grid6"><input type="text" maxlength="255" id="name" name="name" value="" class="std-input"/></div>
	<div class="grid2"><span class="bold red hidden" id="name_error">Required field.</span></div>
	<div class="clrboth"></div>
	
	<div class="grid2"><span class="bold">*Odds:</span></div>
	<div class="grid6"><input type="text" maxlength="25" id="odds" name="odds" value="" class="std-input"/></div>
	<div class="grid2"><span class="bold red hidden" id="odds_error">Required field.</span></div>
	<div class="clrboth"></div>
<!--	
	<div class="grid2"><span class="bold">*Start time:</span></div>
	<div class="grid6"><input type="text" maxlength="255" id="start_time" name="start_time" value="<?php echo sysDateTimeFormat($MATCH->getStartTime());?>" class="std-input"/><button id="start_time_btn">choose</button></div>
	<div class="grid2"><span class="bold red hidden" id="start_time_error">Required field.</span></div>
	<br/> <i>&nbsp; >= <?php echo sysDateTimeFormat($MATCH->getStartTime());?></i>
	<div class="clrboth"></div>
	
	<div class="grid2"><span class="bold">*End time:</span></div>
	<div class="grid6"><input type="text" maxlength="255" id="end_time" name="end_time" value="<?php echo sysDateTimeFormat($TOURNAMENT->getEndTime());?>" class="std-input"/><button id="end_time_btn">choose</button></div>
	<div class="grid2"><span class="bold red hidden" id="end_time_error">Required field.</span></div>
	<br/> <i>&nbsp; <= <?php echo sysDateTimeFormat($TOURNAMENT->getEndTime());?></i>
	<div class="clrboth"></div>
-->	
	<div class="grid2">&nbsp;</div>
	<div class="grid6"><input type="submit" class="button" /> <?php echo loader_image('id="loader_image" class="hidden"');?></div>
	<div class="clrboth"></div>	
	
</form>
<?php else:?>
<form action="<?php echo site_url('admin/dataman/match/event_submit');?>" name="event_submit" id="event_submit" method="post" enctype="multipart/form-data" >
	<?php 
		$EVENT = $ci->event_entity->init('id',$id);
	?>
	<input type="hidden" name="id" id="id" value="<?php echo $id;?>" />
	<input type="hidden" name="match_id" id="match_id" value="<?php echo $match_id;?>" />
	
	<div class="grid2"><span class="bold">*Event Category:</span></div>
	<div class="grid6"><?php echo form_dropdown( 'event_category_id',
								$options = $eventCategoryDataArray,
								$selected = array($EVENT->getEventCategoryId()),
								"id='event_category_id'"
							);	?></div>	
	<div class="clrboth"></div>
	
	<div class="grid2"><span class="bold">*Event Name:</span></div>
	<div class="grid6"><input type="text" maxlength="255" id="name" name="name" value="<?php echo $EVENT->getName();?>" class="std-input"/></div>
	<div class="grid2"><span class="bold red hidden" id="name_error">Required field.</span></div>
	<div class="clrboth"></div>
	
	<div class="grid2"><span class="bold">*Odds:</span></div>
	<div class="grid6"><input type="text" maxlength="25" id="odds" name="odds" value="<?php echo $EVENT->getOdds();?>" class="std-input"/></div>
	<div class="grid2"><span class="bold red hidden" id="odds_error">Required field.</span></div>
	<div class="clrboth"></div>
<!--	
	<div class="grid2"><span class="bold">*Start time:</span></div>
	<div class="grid6"><input type="text" maxlength="255" id="start_time" name="start_time" value="<?php echo sysDateTimeFormat($EVENT->getStartTime());?>" class="std-input"/><button id="start_time_btn">choose</button></div>
	<div class="grid2"><span class="bold red hidden" id="start_time_error">Required field.</span></div>
	<br/> <i>&nbsp; > <?php echo sysDateTimeFormat($MATCH->getStartTime());?></i>
	<div class="clrboth"></div>
	
	<div class="grid2"><span class="bold">*End time:</span></div>
	<div class="grid6"><input type="text" maxlength="255" id="end_time" name="end_time" value="<?php echo sysDateTimeFormat($EVENT->getEndTime());?>" class="std-input"/><button id="end_time_btn">choose</button></div>
	<div class="grid2"><span class="bold red hidden" id="end_time_error">Required field.</span></div>
	<br/> <i>&nbsp; < <?php echo sysDateTimeFormat($TOURNAMENT->getEndTime());?></i>
	<div class="clrboth"></div>
-->	
	<div class="grid2">&nbsp;</div>
	<div class="grid6"><input type="submit" class="button" /> <?php echo loader_image('id="loader_image" class="hidden"');?></div>
	<div class="clrboth"></div>	
	
</form>
<?php endif;?>